package src.IO;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;

public class Dataout {
    public static void main(String[] args) throws Exception {
        testDataInputStream();
    }

    public static void testDataInputStream() throws Exception {
        DataOutputStream out = new DataOutputStream(new FileOutputStream("e:\\a.txt"));
        out.writeBoolean(true);//将一个boolean值以1-byte值的形式写入基础输出流
        out.writeByte(15);//0x05 将一个byte值以1-byte值形式写入基础输出流
        out.writeBytes("abc");//将字符串按字节顺序写出到基础输出流
        out.writeChar('x');
        out.writeChars("zxc");
        out.writeLong(110);
        out.writeUTF("中国");
        out.close();
        DataInputStream in=new DataInputStream(new FileInputStream("e:\\a.txt"));
        System.out.println(in.readBoolean());
        System.out.println(in.readByte());
        System.out.println(in.readByte());
        System.out.println(in.readByte());
        System.out.println(in.readByte());
        System.out.println(in.readChar());
        System.out.println(in.readChar());
        System.out.println(in.readChar());
        System.out.println(in.readChar());
        System.out.println(in.readLong());
        System.out.println(in.readUTF());
        in.close();
    }
}